﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

using System.Net;
using System.Net.Mail;

public partial class mail : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            MailMessage msg = new MailMessage();
            msg.From = new MailAddress(txtFrom.Text);
            msg.To.Add(txtTo.Text);
            msg.Subject = txtSubject.Text;
            msg.Body = txtMessage.Text;
            SmtpClient sc = new SmtpClient("smtp.gmail.com");
            sc.Port = 25;
            sc.Credentials = new NetworkCredential(txtFrom.Text, txtPword.Text);
            sc.EnableSsl = true;
            sc.Send(msg);
            Response.Write("mail send");
        }
        catch(Exception ex) 
        {
            Response.Write(ex.Message);
        }

    }
}
